package com.foreknow.springboot_demo.mapper;

import com.foreknow.springboot_demo.po.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.SQLException;

@Mapper
public interface UserMapper {
    /**
     * 根据用户编号与密码查询用户信息
     * @param userId
     * @param password
     * @return
     */
    @Select("select * from user where userId = #{userId} and password = #{password}")
    public User getUserByIdByPass(@Param("userId") String userId,@Param("password") String password);

    /**
     * 根据用户编号查询用户表返回的行数
     * @param userId
     * @return
     */
    @Select("select count(*) from user where userId = #{userId}")
    public Integer getUserById(String userId);

    /**
     * 向用户表中添加一条记录
     * @param userId
     * @param password
     * @param userName
     * @param userSex
     * @return
     */

    @Insert("insert into user(userId,password,userName,userSex) values (#{userId},#{password},#{userName},#{userSex}) ")
    public Integer saveUser(@Param("userId") String userId,@Param("password") String password,@Param("userName") String userName,@Param("userSex") int userSex);
}
